function reset() {
	$("#frm_login")[0].reset();
}

function rgreset() {
	$("#frm_register")[0].reset();
}

function register() {

	var rguname = $("#rguname").val();
	if(rguname.length == 0) {
		layer.tips("用户名不能为空!", "#rguname", {
			tips: 2,
			time: 1000
		});
		return;
	}

	var rgupwd = $("#rgupwd").val();
	if(rgupwd.length == 0) {
		layer.tips("新密码不能为空！", "#rgupwd", {
			tips: 2,
			time: 1000
		});
		return;
	}

	var rupwd = $("#rupwd").val();
	if(rupwd.length == 0) {
		layer.tips("确认密码不能为空！", "#rupwd", {
			tips: 2,
			time: 1000
		});
		return;
	}

	var rgupwd = $("#rgupwd").val();
	if(rgupwd.length < 6) {
		layer.tips("密码长度应在6-12位！", "#rgupwd", {
			tips: 2,
			time: 1000
		});
		return;
	}

	var rgupwd = $("#rgupwd").val();
	if(rgupwd.length > 12) {
		layer.tips("密码长度应在6-12位！", "#rgupwd", {
			tips: 2,
			time: 1000
		});
		return;
	}

	/*var rgupwd=$("#rgupwd").val();
		var patrn = /^[\w_-]{6,12}$/; 
			if(!patrn.exec(rgupwd)){
				layer.tips("密码格式不合法！","#rgupwd",{
					tips:1,
					time:1000
				});
				return;
			}*/

	/*var rgupwd=$('#rgupwd').val();
		var rupwd=$('#rupwd').val();
			var patrn = /^[\w_-]{6,12}$/; 
			if(!patrn.exec(rgupwd)){
				layer.tips("密码格式不合法！","#rgupwd",{
					tips:1,
					time:1000
				});
				return;
			}
			if(rgupwd!=rupwd){
				layer.tips("两次输入的密码应相同！","#rgupwd","rupwd",{
					tips:1,
					time:1000
				});
				return;
			}*/

	var rupwd = $('#rupwd').val();
	var rgupwd = $('#rgupwd').val();
	var patrn = /^[\w_-]{6,12}$/;
	if(!patrn.exec(rgupwd)) {
		layer.tips("密码格式不合法！", "#rgupwd", {
			tips: 1,
			time: 1000
		});
		return;
	}
	if(rupwd != rgupwd) {
		layer.tips("两次输入的密码应相同！", "#rupwd", "#rgupwd", {
			tips: 1,
			time: 1000
		});
		return;
	}

	var email = $("#rgemail").val();
	var reg = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/
	if(!reg.test(email)) {
		layer.tips("邮箱格式不合法！", "#rgemail", {
			tips: 1,
			time: 1000
		});
		return;
	}

	$.ajax({
		url: "dataJSON/login.json",
		type: "get",
		dataType: "json",
		success: function(result) {

			if(result.code == 1) {
				
				localStorage.setItem("rguname",rguname);
				localStorage.setItem("rgupwd",rgupwd);
				layer.alert("注册成功，您的<br/>用户名是："+rguname+"<br/>密码是："+rgupwd,{icon:1},function(index){
					location.href = "login.html";
					layer.close(index);
				});
				/*alert("注册成功，您的用户名是："+rguname+"    密码是："+rgupwd);*/
				/*location.href = "login.html";*/
			} else {

				layer.msg("登录失败！", {
					icon: 2,
					time: 2000
				});

			}
		},
		error: function() {
			layer.msg("请求服务器失败！", {
				icon: 2,
				time: 2000
			});
		}
	});

}